<!DOCTYPE html>
<html lang="en">
<head>
        {include file="common/meta_new" /}
    <style>
        .loading{
            text-align: center;
            height: 0.3rem;
            line-height: 0.3rem;
            margin-top: 0.15rem;
            color: #C0C0C0;
            font-size: 12px;

        }
    </style>
</head>
<body class="F5">
<div id="app" class="market-level-page">
    <!-- header -->
    <div class="header">
        <div class="header-height"></div>
        <div class="header-wrap">
            <div class="header-content">
                <div class="left">
                    <a href="{:url('index/user/index');}"><div class="go-back"><img src="/static/images/go-back.png" alt=""></div></a>
                    <div class="text">市场级别</div>
                </div>
                <div class="title"></div>
            </div>
        </div>
    </div>
    <div class="top-wrap">
        <div class="layer-1"></div>
        <div class="layer-2"><img src="/static/images/market-bg.png" alt=""></div>
        <div class="layer-3">
            <div class="title-box">
                <div class="left"><img src="/static/images/diamond.png" alt=""></div>
                <div class="right">区域</div>
            </div>
            <div class="middle-box">
                <div class="left">地区:{$user['province']|default=''}{$user['city']|default=''}{$user['area']|default=''}</div>
            </div>
            <div class="bottom-box">
                <div class="item">
                    <div class="money-box"><span>￥</span>{$user['weighting_score']|default='--'}</div>
                    <div class="text">加权分红</div>
                </div>
                <div class="item">
                    <div class="money-box"><span>￥</span>{$user['orderflow_score']|default='--'}</div>
                    <div class="text">流水收益</div>
                </div>
            </div>
        </div>
    </div>
    <div class="content-wrap">
        <div class="top-box">
            <div class="fh"></div>
            <div class="title">分红明细</div>
        </div>
        <div class="table-header">
            <div>时间</div>
            <div>类型</div>
            <div>数量</div>
        </div>
        <div id="rm_con" class="list">
        
    </div>
</div>
<script src="/static/js/common.js"></script>
        <script language="javascript">
            function getScrollTop() {
                var scrollTop = 0;
                if (document.documentElement && document.documentElement.scrollTop) {
                    scrollTop = document.documentElement.scrollTop;
                } else if (document.body) {
                    scrollTop = document.body.scrollTop;
                }
                return scrollTop;
            }
            function getClientHeight() {
                var clientHeight = 0;
                if (document.body.clientHeight && document.documentElement.clientHeight) {
                    clientHeight = Math.min(document.body.clientHeight, document.documentElement.clientHeight);
                } else {
                    clientHeight = Math.max(document.body.clientHeight, document.documentElement.clientHeight);
                }
                return clientHeight;
            }
            function getScrollHeight() {
                return Math.max(document.body.scrollHeight, document.documentElement.scrollHeight);
            }

            var page = 1;
            var lock = 1;
            function load_html(result) {
                var lists = result.data;
                if (lists.length > 0) {
                    for (i = 0, ii = lists.length; i < ii; i++) {
                        var tmp_html = '';
                        var tmp_data = lists[i];
                        if (tmp_data.avatar == false || tmp_data.avatar == '') {
                            tmp_data.avatar = '/public/image/tx.jpg';
                        }
                        tmp_html += '<div class="item">';
                        tmp_html += '<div class="row">';
                        tmp_html += '    <div class="datetime">'+tmp_data.add_time+'</div>';
                        if(tmp_data.type==1){
                            
                        tmp_html += '    <div class="middle">加权分红'+tmp_data.percent+'%</div>';
                        }else if(tmp_data.type==2){
                            
                        tmp_html += '     <div class="middle">流水收益</div>';
                        }else{
                            
                        tmp_html += '    <div class="middle">其他 '+tmp_data.percent+'%</div>';
                        }
                        
                        tmp_html += '    <div class="last"><span>￥</span>'+tmp_data.score+'</div>';
                        tmp_html += '</div>';

                        $('#rm_con').append(tmp_html);
                    }
                    if (lists.length <= 0) {
                        $('#rm_con').append('<div class="loading">- 加载完成 -</div>');
                    } else {
                        lock = 0;//解除加载锁
                    }
                } else {
                    $('#rm_con').append('<div class="loading">- 加载完成 -</div>');
                }
            }
            function load_url() {
                var url = '{:url("index/Bazaar/index")}';
                $.post(url,{"page":page,"type":0}, function (ret) {
                    load_html(ret);
                }, 'json');
            }

            $(function () {
                $(window).scroll(function () {
                    var sH = getScrollHeight();
                    var sT = getScrollTop();
                    var cH = getClientHeight();
                    if (sH - cH - sT < 50) {
                        if (lock == 0) {
                            lock = 1;//防止重复加载
                            page = page + 1;
                            load_url();
                        }
                    }
                    console.log(sH + ',' + sT + ',' + cH);
                });
                load_url() ;
            });
            
        </script>
</body>
</html>